In a multiprocessing computing environment, more than one process may actively use the resources available in the computing environment. To avoid corruption of a resource due to the concurrent use or modification by multiple processes, a process may lock a resource during use and release the lock after the process has finished using the resource. A deadlock situation may occur when two processes or two elements (e.g., threads) in a process each wait for the other to release a lock on the same resource, thus suspending execution for an infinite period of time.
Deadlocks may be prevented by requiring processes and process elements to declare which resources they want to allocate in advance, so that a system may restrict allocation of resources to requests that do not lead to deadlocks. Yet, for many systems, it is difficult to know what resources a process or thread will request in advance.
Other solutions for preventing deadlocks involve using non-blocking synchronization or avoiding circular wait. Implementation of these solutions, however, is limited to synchronization algorithms that behave in ways that are often difficult to enforce on existing systems. Another possible solution is to use a transaction mechanism with the option to roll back transactions that lead to deadlocks, but roll back has high overhead costs.
Thus, methods and systems for preventing deadlocks are needed that are able to overcome the above-noted shortcomings.